Matching Nuts and Bolts in O(n log n) Time

نویسندگان

  • János Komlós
  • Yuan Ma
  • Endre Szemerédi
چکیده

Given a set of n nuts of distinct widths and a set of n bolts such that each nut corresponds to a unique bolt of the same width, how should we match every nut with its corresponding bolt by comparing nuts with bolts? (No comparison is allowed between two nuts or two bolts.) The problem can be naturally viewed as a variant of the classic sorting problem as follows. Given two lists of n numbers each such that one list is a permutation of the other, how should we sort the lists by comparisons only between numbers in different lists? We give an O(n logn)-time deterministic algorithm for the problem. This is optimal up to a constant factor and answers an open question posed by Alon et al. [Proceedings of the 5th Annual ACM-SIAM Symposium on Discrete Algorithms, 1994, pp. 690–696]. Moreover, when copies of nuts and bolts are allowed, our algorithm runs in optimal O(logn) time on n processors in Valiant’s parallel comparison tree model. Our algorithm is based on the AKS sorting algorithm with substantial modifications.

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Matching Nuts and Bolts Faster

The problem of matching nuts and bolts is the following Given a collection of n nuts of distinct sizes and n bolts such that there is a one to one correspondence between the nuts and the bolts nd for each nut its corresponding bolt We can only compare nuts to bolts That is we can neither compare nuts to nuts nor bolts to bolts This humble restriction on the comparisons appears to make this prob...

متن کامل

Matching Nuts and Bolts Optimally∗

The nuts and bolts problem is the following : Given a collection of n nuts of distinct sizes and n bolts of distinct sizes such that for each nut there is exactly one matching bolt, find for each nut its corresponding bolt subject to the restriction that we can only compare nuts to bolts. That is we can neither compare nuts to nuts, nor bolts to bolts. This humble restriction on the comparisons...

متن کامل

Matching Nuts and Bolts Noga Alon

We describe a procedure which may be helpful to any disorganized carpenter who has a mixed pile of bolts and nuts and wants to nd the corresponding pairs of bolts and nuts. The procedure uses our (and the carpenter's) ability to construct e ciently highly expanding graphs. The problem considered is given a collection of n bolts of distinct widths and n nuts such that there is a 1-1 corresponden...

متن کامل

Matching Nuts and Bolts Extended Abstract

We describe a procedure which may be helpful to any disorganized carpenter who has a mixed pile of bolts and nuts and wants to nd the corresponding pairs of bolts and nuts. The procedure uses our (and the carpenter's) ability to construct e ciently highly expanding graphs. The problem considered is given a collection of n bolts of distinct widths and n nuts such that there is a 1-1 corresponden...

متن کامل

Tree Pattern Matching and Subset Matching in Deterministic O(n log3 n)-time

The main goal of this paper is to give an O(n log 3 n) time deterministic algorithm for the the Subset Matching problem. This immediately yields an algorithm of the same eeciency for the Tree Pattern Matching problem. We also give an O(n log 3 n= log log n) time randomized algorithm for these problems. Finally, we give a O(n log n(z + log n)) time deterministic algorithm for a useful specializa...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:
  • SIAM J. Discrete Math.

دوره 11  شماره 

صفحات  -

تاریخ انتشار 1998